﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Productos.aspx.cs" Inherits="SistemaFacturacionWeb.Formulario_web12" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            width: 193px;
        }
        .auto-style3 {
            height: 47px;
        }
        .auto-style4 {
            width: 193px;
            height: 47px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h1>Productos</h1>
    <p>&nbsp;</p>
    <table class="auto-style1">
        <tr>
            <td class="auto-style4" style="text-align: right">Descripción: *</td>
            <td class="auto-style2">
                <asp:TextBox ID="TxtDescripcionProducto" runat="server" Width="150px"></asp:TextBox>
            </td>
            <td style="text-align: right">
                Stock: *</td>
            <td>
                <asp:TextBox ID="TxtStocProducto" runat="server" Width="150px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style3" style="text-align: right">Precio: *</td>
            <td class="auto-style4">
                <asp:TextBox ID="TxtPrecioProducto" runat="server" Width="150px"></asp:TextBox>
                <br />
            </td>
            <td class="auto-style3" colspan="2">
                <br />
            </td>
        </tr>
        <tr>
            <td class="auto-style4" style="text-align: right; vertical-align: top;">Notas:</td>
            <td colspan="3">
                <asp:TextBox ID="txtNotasProducto" runat="server" Height="91px" TextMode="MultiLine" Width="460px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style4" style="text-align: right">IVA: *</td>
            <td class="auto-style2">
               
                <asp:DropDownList ID="DropDownListIva" runat="server" Width="172px" DataSourceID="SqlDataSourceIva" DataTextField="Descripcion" DataValueField="IDIVA" Height="16px">
                </asp:DropDownList>
             
            </td>
            <td class="auto-style5" colspan="2">
                <asp:SqlDataSource ID="SqlDataSourceIva" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" SelectCommand="SELECT IDIVA, Descripcion FROM IVA
UNION
SELECT '','[Seleccione una tarifa]'
ORDER BY Descripcion"></asp:SqlDataSource>
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="auto-style4" style="text-align: right">Departamento: *</td>
            <td class="auto-style2">
          
                <asp:DropDownList ID="DropDownListdepartamento" runat="server" Width="173px" DataSourceID="SqlDataSourceDepartamento" DataTextField="Descripcion" DataValueField="IDDepartamento" Height="18px">
                </asp:DropDownList>
                
            </td>
            <td class="auto-style5" colspan="2">
                <asp:SqlDataSource ID="SqlDataSourceDepartamento" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" SelectCommand="SELECT IDDepartamento, Descripcion FROM Departamento 
UNION
SELECT '','[Seleccione un departamento]'
ORDER BY Descripcion"></asp:SqlDataSource>
                <asp:Label ID="LabelMensajeAltaProducto" runat="server" Font-Bold="True" Font-Names="Cambria" Font-Size="Large" ForeColor="Maroon"></asp:Label>
            </td>
        </tr>
    </table>
    <asp:Button ID="BtnGuardarProducto" runat="server" Text="Guardar" OnClick="BtnGuardarProducto_Click" />
    <br />
    <p>
        <asp:GridView ID="GridViewProductos" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="IDProducto" DataSourceID="SqlDataSourceProductos" EmptyDataText="No hay registros de datos para mostrar." ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField HeaderText="Operaciones" ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="IDProducto" HeaderText="ID Producto" ReadOnly="True" SortExpression="IDProducto" />
                <asp:BoundField DataField="Descripcion" HeaderText="Descripción" SortExpression="Descripcion" />
                <asp:BoundField DataField="Precio" HeaderText="Precio" SortExpression="Precio">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="Stock" HeaderText="Stock" SortExpression="Stock">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="Notas" HeaderText="Notas" SortExpression="Notas" />
                <asp:TemplateField HeaderText="ID IVA" SortExpression="IDIVA">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSourceIva" DataTextField="Descripcion" DataValueField="IDIVA" SelectedValue='<%# Bind("IDIVA") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSourceIva" DataTextField="Descripcion" DataValueField="IDIVA" Enabled="False" SelectedValue='<%# Bind("IDIVA") %>'>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="ID Departamento" SortExpression="IDDepartamento">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDataSourceDepartamento" DataTextField="Descripcion" DataValueField="IDDepartamento" SelectedValue='<%# Bind("IDDepartamento") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSourceDepartamento" DataTextField="Descripcion" DataValueField="IDDepartamento" Enabled="False" SelectedValue='<%# Bind("IDDepartamento") %>'>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSourceProductos" runat="server" ConnectionString="<%$ ConnectionStrings:FacturacionConnectionString1 %>" DeleteCommand="DELETE FROM [Producto] WHERE [IDProducto] = @IDProducto" InsertCommand="INSERT INTO [Producto] ([Descripcion], [Precio], [Stock], [Notas], [IDIVA], [IDDepartamento]) VALUES (@Descripcion, @Precio, @Stock, @Notas, @IDIVA, @IDDepartamento)" ProviderName="<%$ ConnectionStrings:FacturacionConnectionString1.ProviderName %>" SelectCommand="SELECT [IDProducto], [Descripcion], [Precio], [Stock], [Notas], [IDIVA], [IDDepartamento] FROM [Producto]" UpdateCommand="UPDATE [Producto] SET [Descripcion] = @Descripcion, [Precio] = @Precio, [Stock] = @Stock, [Notas] = @Notas, [IDIVA] = @IDIVA, [IDDepartamento] = @IDDepartamento WHERE [IDProducto] = @IDProducto">
            <DeleteParameters>
                <asp:Parameter Name="IDProducto" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Descripcion" Type="String" />
                <asp:Parameter Name="Precio" Type="Decimal" />
                <asp:Parameter Name="Stock" Type="Int32" />
                <asp:Parameter Name="Notas" Type="String" />
                <asp:Parameter Name="IDIVA" Type="Int32" />
                <asp:Parameter Name="IDDepartamento" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Descripcion" Type="String" />
                <asp:Parameter Name="Precio" Type="Decimal" />
                <asp:Parameter Name="Stock" Type="Int32" />
                <asp:Parameter Name="Notas" Type="String" />
                <asp:Parameter Name="IDIVA" Type="Int32" />
                <asp:Parameter Name="IDDepartamento" Type="Int32" />
                <asp:Parameter Name="IDProducto" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </p>
</asp:Content>
